home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2003 September / The Sunday Times - The Month 2003-09.iso / mac / The Month SEP 03 / assets / bespoke / feature / feature_shell.swf / scripts / frame_2 / DoAction.as
Text File  |  2003-08-12  |  12KB  |  408 lines

  1. stop();
  2. X_OFFSET = 15;
  3. Y_OFFSET = 112;
  4. Feature = new Object();
  5. Feature.depthCount = 1;
  6. var stage = this;
  7. var navOpen = false;
  8. var sliderPositions = [35.9,205.2,411.1,484.9,496,507.1,518.2,529.3,660.1];
  9. var sliderLabels = ["introduction","section1","section2","section2_1_1","section2_2_1","section2_3_1","section2_4_1","section2_5_1","section3"];
  10. var fileToLoad;
  11. var currentFile;
  12. var basePath = "feature_movies/";
  13. var clipNames = ["section1","section2","lies01","lies02","lies03","lies04","lies05","section3"];
  14. var barColour0 = [35,118,214];
  15. var barColour1 = [35,118,214];
  16. var barColour2 = [204,0,0];
  17. var barColour3 = [255,102,153];
  18. var barColour4 = [204,0,0];
  19. var barColour5 = [35,118,214];
  20. var barColour6 = [255,255,255];
  21. var barColour7 = [255,51,102];
  22. var barColour8 = [255,255,255];
  23. var barColour9 = [255,102,153];
  24. var barColour10 = [35,118,214];
  25. var textColour1 = [255,255,255];
  26. var textColour2 = [255,255,255];
  27. var textColour3 = [255,255,255];
  28. var textColour4 = [0,0,0];
  29. var textColour5 = [255,255,255];
  30. var textColour6 = [255,255,255];
  31. var textColour7 = [221,65,47];
  32. var textColour8 = [0,204,255];
  33. var textColour9 = [61,118,148];
  34. var textColour10 = [255,255,255];
  35. var textColour11 = [0,0,0];
  36. var sliderColour1 = [255,255,255];
  37. var sliderColour2 = [255,255,255];
  38. var sliderColour3 = [255,255,255];
  39. var sliderColour4 = [255,255,255];
  40. var sliderColour5 = [255,255,255];
  41. var sliderColour6 = [255,255,255];
  42. var sliderColour7 = [221,65,47];
  43. var sliderColour8 = [255,255,255];
  44. var sliderColour9 = [61,118,148];
  45. var sliderColour10 = [255,255,255];
  46. var sliderColour11 = [255,255,255];
  47. var idCount = 1;
  48. var idRef;
  49. var objsInTransition = new Array();
  50. var intIds = new Array();
  51. this.createEmptyMovieClip("introHolder",2);
  52. introHolder._x = X_OFFSET;
  53. introHolder._y = Y_OFFSET;
  54. checkVideoProgress = function()
  55. {
  56.    if(this._currentframe == this._totalframes && this._totalframes > 1)
  57.    {
  58.       this._parent.isIntroPlaying = false;
  59.       if(this._parent.videoLoader.numPlays == 0)
  60.       {
  61.          this._parent.createNav();
  62.          this._parent.videoLoader.numPlays = this._parent.videoLoader.numPlays + 1;
  63.       }
  64.       this._parent.currentFile = this._parent.clipHandle = this._parent.clipNames[0];
  65.       this._parent[clipHandle].gotoAndPlay(1);
  66.       this._visible = false;
  67.       this.gotoAndStop(1);
  68.       delete this.onEnterFrame;
  69.    }
  70. };
  71. createNav = function()
  72. {
  73.    this.attachMovie("menuBtn","menuBtn",3);
  74.    this.menuBtn._x = 33.4 + X_OFFSET;
  75.    this.menuBtn._y = 363.3 + Y_OFFSET;
  76.    mSliderBarX = 19 + X_OFFSET;
  77.    mSliderBarY = 374 + Y_OFFSET;
  78.    this.attachMovie("sliderBg","sliderBg",4);
  79.    this.sliderBg._x = mSliderBarX;
  80.    this.sliderBg._y = mSliderBarY;
  81.    this.attachMovie("slider","slider",5);
  82.    this.slider.x = stage.slider._x = stage.sliderBg._x + sliderPositions[1];
  83.    this.slider.y = stage.slider._y = mSliderBarY - stage.slider._height / 2;
  84.    this.slider.maxSlide = stage.sliderBg._x + stage.sliderBg._width - stage.slider._width / 2;
  85.    this.slider.minSlide = stage.sliderBg._x + stage.slider._width / 2;
  86.    this.slider.inAction = false;
  87.    barCol = new Color(this.sliderBg.bg.bgBar);
  88.    colTransform = new Object();
  89.    colTransform = {ra:"0",rb:barColour1[0],ga:"0",gb:barColour1[1],ba:"0",bb:barColour1[2],aa:"100",ab:"0"};
  90.    barCol.setTransform(colTransform);
  91.    delete colTransform;
  92.    objsInTransition.push(this.sliderBg.bg.bgBar);
  93.    sliderCol = new Color(this.slider);
  94.    colTransform = new Object();
  95.    colTransform = {ra:"0",rb:sliderColour1[0],ga:"0",gb:sliderColour1[1],ba:"0",bb:sliderColour1[2],aa:"100",ab:"0"};
  96.    sliderCol.setTransform(colTransform);
  97.    delete colTransform;
  98.    objsInTransition.push(this.slider);
  99.    textCol = new Color(this.menuBtn);
  100.    colTransform = new Object();
  101.    colTransform = {ra:"0",rb:textColour1[0],ga:"0",gb:textColour1[1],ba:"0",bb:textColour1[2],aa:"100",ab:"0"};
  102.    textCol.setTransform(colTransform);
  103.    delete colTransform;
  104.    objsInTransition.push(this.menuBtn);
  105.    Feature.activeBut = "butFantasy";
  106. };
  107. clickNav = function(i, c)
  108. {
  109.    var index = i;
  110.    videoFullscreenClose();
  111.    silentStream.gotoAndPlay(1);
  112.    if(sliderLabels[i] == currentFile)
  113.    {
  114.       stopAllSounds();
  115.       this[clipHandle].replayMovie();
  116.    }
  117.    else
  118.    {
  119.       if(index == 0 && isIntroPlaying == false | (index == 0 && isIntroPlaying == null))
  120.       {
  121.          this[clipHandle].removeMovieClip();
  122.          isIntroPlaying = true;
  123.          clipHandle = "introVideoClip";
  124.          currentFile = "introVideoClip";
  125.          videoLoader.gotoAndPlay(3);
  126.          if(videoLoader.numPlays > 0)
  127.          {
  128.             slider.inAction = true;
  129.             slider.onEnterFrame = function()
  130.             {
  131.                var distanceToMove = stage.sliderBg._x + sliderPositions[0] - this._x;
  132.                this._x += distanceToMove / 8;
  133.                if(Math.abs(distanceToMove) < 1)
  134.                {
  135.                   delete this.onEnterFrame;
  136.                   slider.inAction = false;
  137.                }
  138.             };
  139.             introHolder.play();
  140.          }
  141.          setColourScheme(c);
  142.       }
  143.       else if(index == 0 && isIntroPlaying == true)
  144.       {
  145.          introHolder.gotoAndPlay(1);
  146.       }
  147.       else if(index == 1 && isIntroPlaying == true)
  148.       {
  149.          introHolder.gotoAndStop(1);
  150.          introHolder._visible = false;
  151.          isIntroPlaying = false;
  152.          currentFile = clipHandle = sliderLabels[i];
  153.          setColourScheme(c);
  154.          introHolder.stop();
  155.          introHolder._visible = false;
  156.          slider.inAction = true;
  157.          slider.onEnterFrame = function(index)
  158.          {
  159.             var distanceToMove = stage.sliderBg._x + sliderPositions[i] - this._x;
  160.             this._x += distanceToMove / 8;
  161.             if(Math.abs(distanceToMove) < 1)
  162.             {
  163.                delete this.onEnterFrame;
  164.                slider.inAction = false;
  165.             }
  166.          };
  167.       }
  168.       else
  169.       {
  170.          currentFile = sliderLabels[i];
  171.          isIntroPlaying = false;
  172.          setColourScheme(c);
  173.          introHolder.stop();
  174.          introHolder._visible = false;
  175.          this[clipHandle].removeMovieClip();
  176.          clipHandle = clipNames[i - 1];
  177.          this.createEmptyMovieClip(clipNames[i - 1],1);
  178.          this[clipHandle]._x = X_OFFSET;
  179.          this[clipHandle]._y = Y_OFFSET;
  180.          slider.inAction = true;
  181.          slider.onEnterFrame = function(index)
  182.          {
  183.             var distanceToMove = stage.sliderBg._x + sliderPositions[i] - this._x;
  184.             this._x += distanceToMove / 8;
  185.             if(Math.abs(distanceToMove) < 1)
  186.             {
  187.                delete this.onEnterFrame;
  188.                slider.inAction = false;
  189.             }
  190.          };
  191.          loadMovie(basePath + sliderLabels[i] + ".swf",this[clipHandle]);
  192.       }
  193.       doColourise("sliderBg.bg.bgBar","barColour" + i,"barCol");
  194.       doColourise("slider","sliderColour" + c,"sliderCol");
  195.       doColourise("menuBtn","textColour" + c,"textCol");
  196.    }
  197. };
  198. loadSection1 = function(numVideoPlays)
  199. {
  200.    this.createEmptyMovieClip(clipNames[0],1);
  201.    section1._x = X_OFFSET;
  202.    section1._y = Y_OFFSET;
  203.    loadMovie(basePath + "section1.swf","section1");
  204. };
  205. tweenMovement = function()
  206. {
  207.    if(stage.ghostSlider._visible)
  208.    {
  209.       stage.ghostSlider._x += (stage._xmouse - stage.ghostSlider._x) / 8;
  210.       if(stage.ghostSlider._x > stage.ghostSlider.maxSlide)
  211.       {
  212.          stage.ghostSlider._x = stage.ghostSlider.maxSlide;
  213.       }
  214.       else if(stage.ghostSlider._x < stage.ghostSlider.minSlide)
  215.       {
  216.          stage.ghostSlider._x = stage.ghostSlider.minSlide;
  217.       }
  218.    }
  219. };
  220. createGhostSlider = function()
  221. {
  222.    this.attachMovie("slider","ghostSlider",6);
  223.    this.ghostSlider._x = this.slider._x;
  224.    this.ghostSlider._y = this.slider._y + 3;
  225.    this.ghostSlider.maxSlide = this.sliderBg._x + this.sliderBg._width - this.ghostSlider._width / 2;
  226.    this.ghostSlider.minSlide = this.sliderBg._x + this.ghostSlider._width / 2;
  227.    this.ghostSlider._alpha = 40;
  228.    this.ghostSlider._visible = 0;
  229. };
  230. updateNav = function()
  231. {
  232.    if(stage._ymouse > 350 + Y_OFFSET && stage._ymouse < 380 + Y_OFFSET && navOpen == false)
  233.    {
  234.       navOpen = true;
  235.       enableNav();
  236.    }
  237.    else if(stage._ymouse <= 350 + Y_OFFSET | stage._ymouse >= 380 + Y_OFFSET && navOpen == true)
  238.    {
  239.       navOpen = false;
  240.       disableNav();
  241.    }
  242. };
  243. setInterval(updateNav,20);
  244. enableNav = function()
  245. {
  246.    this.createEmptyMovieClip("controller",999999);
  247.    this.controller.onEnterFrame = function()
  248.    {
  249.       if(stage.slider._currentframe == stage.slider._totalframes)
  250.       {
  251.          trace("ghostSlider should be visible");
  252.          this._parent.ghostSlider._visible = 1;
  253.          ghostInterval = setInterval(tweenMovement,15);
  254.          delete this.onEnterFrame;
  255.          this.removeMovieClip();
  256.       }
  257.       else
  258.       {
  259.          stage.slider.nextFrame();
  260.       }
  261.    };
  262.    stage.sliderBg.play();
  263. };
  264. disableNav = function()
  265. {
  266.    stage.sliderBg.onEnterFrame = reverseTimeline;
  267.    stage.createEmptyMovieClip("controller",999999);
  268.    stage.controller.onEnterFrame = function()
  269.    {
  270.       if(stage.slider._currentframe == 1)
  271.       {
  272.          delete this.onEnterFrame;
  273.          this.removeMovieClip();
  274.       }
  275.       else
  276.       {
  277.          stage.slider.prevFrame();
  278.       }
  279.    };
  280.    stage.ghostSlider._visible = 0;
  281.    clearInterval(ghostInterval);
  282. };
  283. reverseTimeline = function()
  284. {
  285.    if(this._currentframe == 1)
  286.    {
  287.       delete this.onEnterFrame;
  288.    }
  289.    else
  290.    {
  291.       this.prevFrame();
  292.    }
  293. };
  294. doColourise = function(targ, colRef, colObj)
  295. {
  296.    var speed = 4;
  297.    var i = 0;
  298.    var intName = colRef + "id" + idCount;
  299.    var numTransitionObjs = objsInTransition.length;
  300.    idCount++;
  301.    do
  302.    {
  303.       if(objsInTransition[i] == targ)
  304.       {
  305.          clearInterval(intIds[i]);
  306.          intIds.splice(i,1);
  307.          objsInTransition.splice(i,1);
  308.       }
  309.       i++;
  310.    }
  311.    while(i < numTransitionObjs);
  312.    
  313.    objsInTransition.push(targ);
  314.    intIds.push(intName);
  315.    var r;
  316.    var g;
  317.    var b;
  318.    r = stage[colRef][0];
  319.    g = stage[colRef][1];
  320.    b = stage[colRef][2];
  321.    idRef = intName;
  322.    stage[intName] = setInterval(changeColour,40,r,g,b,speed,intName,targ,colObj);
  323. };
  324. changeColour = function(r, g, b, speed, name, targ, colObj)
  325. {
  326.    var rInc = (r - stage[colObj].getTransform().rb) / speed;
  327.    var gInc = (g - stage[colObj].getTransform().gb) / speed;
  328.    var bInc = (b - stage[colObj].getTransform().bb) / speed;
  329.    if(rInc < 0)
  330.    {
  331.       rInc = - Math.ceil(Math.abs(rInc));
  332.    }
  333.    if(gInc < 0)
  334.    {
  335.       gInc = - Math.ceil(Math.abs(gInc));
  336.    }
  337.    if(bInc < 0)
  338.    {
  339.       bInc = - Math.ceil(Math.abs(bInc));
  340.    }
  341.    rInc = Math.ceil(rInc);
  342.    gInc = Math.ceil(gInc);
  343.    bInc = Math.ceil(bInc);
  344.    var nr = stage[colObj].getTransform().rb + rInc;
  345.    var ng = stage[colObj].getTransform().gb + gInc;
  346.    var nb = stage[colObj].getTransform().bb + bInc;
  347.    if(nr == 0)
  348.    {
  349.       nr = r;
  350.    }
  351.    if(ng == 0)
  352.    {
  353.       ng = g;
  354.    }
  355.    if(nb == 0)
  356.    {
  357.       nb = b;
  358.    }
  359.    if(nr == r && ng == g && nb == b)
  360.    {
  361.       clearInterval(stage[name]);
  362.    }
  363.    stage[colObj] = new Color(targ);
  364.    colTransform = new Object();
  365.    colTransform = {ra:"0",rb:nr,ga:"0",gb:ng,ba:"0",bb:nb,aa:"100",ab:"0"};
  366.    stage[colObj].setTransform(colTransform);
  367. };
  368. setColourScheme = function(c)
  369. {
  370.    var i;
  371.    var myCol;
  372.    var scheme = c;
  373.    stage.sliderBg.colourScheme = scheme;
  374.    i = 0;
  375.    while(i < stage.sliderBg.navInstances.length)
  376.    {
  377.       var instance = stage.sliderBg.navInstances[i];
  378.       myCol = new Color(stage.sliderBg[instance]);
  379.       myCol.setRGB(stage.sliderBg["linkColour" + scheme]);
  380.       i++;
  381.    }
  382. };
  383. videoFullscreenOpen = function()
  384. {
  385.    lingo("Flsh_featureVideoFullscreenOpen()");
  386. };
  387. videoFullscreenClose = function()
  388. {
  389.    lingo("Flsh_featureVideoFullscreenClose()");
  390. };
  391. clickToAudioSection = function()
  392. {
  393.    this.unloadMovie();
  394.    lingo("Flsh_itemJump(2,\"#0\")");
  395. };
  396. closeFeature = function()
  397. {
  398.    this.unloadMovie();
  399.    lingo("Flsh_splashRestart");
  400. };
  401. _global.lingo = function(str)
  402. {
  403.    getURL("lingo:" + str,"");
  404. };
  405. createGhostSlider();
  406. clickNav(0,1);
  407. stop();
  408.